// 版权归 瞄你个汪 所有。使用本代码应遵守相关法律法规和许可证的要求。
import {Result} from "/@/types/global";
import request from '/@/utils/request';
import {AxiosResponse} from "axios";
import {CaptchaOutput, LoginConfigOutput, LoginInput, LoginOutput, UserInfoOutput} from "/@/types/sysAuth";

/**
 * ⚙ 系统授权控制接口
 * @author 瞄你个汪
 * @since 2024-01-01 12:00:00
 * @method getLoginConfig 获取登录配置
 * @method captcha 获取验证码
 * @method login 用户登录
 * @method getUserInfo 获取用户信息
 */
export function useSysAuthApi() {
    return {
        getLoginConfig: (): Promise<AxiosResponse<Result<LoginConfigOutput>>> => {
            return request({
                url: '/api/sysAuth/loginConfig',
                method: 'post',
            });
        },
        captcha: (): Promise<AxiosResponse<Result<CaptchaOutput>>> => {
            return request({
                url: '/api/sysAuth/captcha',
                method: 'get',
            });
        },
        login: (params?: LoginInput): Promise<AxiosResponse<Result<LoginOutput>>> => {
            return request({
                url: '/api/sysAuth/login',
                method: 'post',
                data: params,
            });
        },
        getUserInfo: (): Promise<AxiosResponse<Result<UserInfoOutput>>> => {
            return request({
                url: '/api/sysAuth/userInfo',
                method: 'post',
            });
        },
    };
}